﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Microsoft.Xna.Framework;

namespace WindowsGame4
{
    class Enemy : Object
    {

        public Enemy(String id, Position2D position, Model model)
            : base(id, position, model)
        {
            type = Object.TypeObject.enemy;
            speed = 8;
        }

        public Object checkBomb()
        {
            GameInfo gameInfo = GameInfo.getInstance();

            Dictionary<String, Object> aux = gameInfo.getObjects("bomb");
            foreach (KeyValuePair<String, Object> j in aux)
            {
                Bomb bomb = (Bomb)j.Value;
                double distance = Math.Sqrt(Math.Pow(this.position.X - bomb.Position.X, 2) + Math.Pow(this.position.Y - bomb.Position.Y, 2));
                //System.Console.WriteLine("distance: " + distance);
                if (distance <= bomb.Distance * 64*2)
                    return bomb;
                /*
                Rectangle rectEnemy = this.Colision;
                // Use wheel to the colision
                if (this.Direction != null)
                {
                    if (this.Direction.getDirection() == "left" || this.Direction.getDirection() == "right")
                        rectEnemy = this.HorizontalColision;
                    if (this.Direction.getDirection() == "up" || this.Direction.getDirection() == "down")
                        rectEnemy = this.VerticalColision;
                }

                Rectangle a = new Rectangle(this.Position.X + rectEnemy.X, this.Position.Y + rectEnemy.Y, rectEnemy.Width, rectEnemy.Height);
                Rectangle b = new Rectangle(bomb.Position.X + bomb.Colision.X, bomb.Position.Y + bomb.Colision.Y, bomb.Colision.Width, bomb.Colision.Height);
                if (Game1.modeDebug)
                {
                    Game1.spriteBatch.Begin();
                    Game1.spriteBatch.Draw(Game1.textColision, a, Color.White);
                    Game1.spriteBatch.Draw(Game1.textColision, b, Color.White);
                    Game1.spriteBatch.End();
                }
                if (gameInfo.rectangleColission(a, b))
                    return bomb;*/

            }
            return null;
        }
    }
}